﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EazyCMS.Model;

namespace EazyCMS.BLL
{
    public partial class tools_helper
    {
        private readonly Model.siteconfig siteConfig = new BLL.siteconfig().loadConfig(); //获得站点配置信息
        private readonly DAL.tools_helper dal;

        public tools_helper()
        {
            dal = new DAL.tools_helper(siteConfig.sysdatabaseprefix);
        }


        #region 访问统计的基本方法================================
        /// <summary>
        /// 向Ip地址信息库中添加数据
        /// </summary>
        /// <returns></returns>
        public int insert_visit_num(visit_num ipinfo)
        {
            return dal.insert_visit_num(ipinfo);
        }
        /// <summary>
        /// 根据Ip地址进行查询,返回查询结果
        /// </summary>
        /// <returns></returns>
        public int select_visit_byip(string ipadress)
        {
            return dal.select_visit_byip(ipadress);
        }
        /// <summary>
        /// 根据id更新ip记录
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int update_visit_num(visit_num ipinfo)
        {
            return dal.update_visit_num(ipinfo);

        }
        //根据IP地址取得相关信息
        public visit_num get_visit_byip(string ip)
        {
            return dal.get_visit_byip(ip);



        }
        /// <summary>
        /// 如果该IP地址信息时间不在今天范围内则删除该ip地址相关信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int delete_visit_num(int id)
        {
            return dal.delete_visit_num(id);
        }


        /// <summary>
        /// 清空ip信息数据库
        /// </summary>
        public void delete_visit_all(DateTime d1, DateTime d2)
        {
            dal.delete_visit_all(d1, d2);

        }
        ///-------------------更新访问数据----------------------////

        ///更新访问数据
        /// 如果是当天的总数和当天统计数都累加，反之不在当天范围内  总数累加  当天访问量置为1
        /////
        public void updatenum()
        {

            dal.updatenum();

        }

        #endregion
        #region

        #endregion
    }
}
